<template>
	<view class="">
		<!-- 登陆密码 -->
		 <view class="bg-f has-pd-20" @tap="editpass">
		 	<text>登陆密码</text>
			<view class="has-floatr is-grey has-right-icon">
				修改
				<image src="../../static/img/common/right_ico_grey.png" mode="" ></image>
			</view>			
		 </view>
		 <!-- 身份认证 -->
		  <view class="bg-f has-pd-20" @tap="editcard">
		  	<text>身份认证</text>
		 	<view class="has-floatr is-grey has-right-icon">
		 		{{ user_card_rz ===0 ? '未认证' : '已认证'}}
		 		<image src="../../static/img/common/right_ico_grey.png" mode="" ></image>
		 	</view>			
		  </view>
		 <!-- 语音 -->
		 <view class="bg-f has-pd-20 has-mgt-20">
		  <view class="swiper-list">
			 <view class="uni-list-cell uni-list-cell-pd">
				 <view class="uni-list-cell-db has-floatl">语音</view>
				 <switch :checked="indicatorDots" @change="changeIndicatorDots" class="has-floatr"/>
			 </view>			 
			</view>
		 </view>
		 <!-- 退出登陆 -->
		 <view class="has-pd-20">
			 <button type="warn" @click="outme" class="z-yello">退出登陆</button>
		 </view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				indicatorDots:false,
				userinfo:[],
				foxtoken:'',
				user_card_rz:0
			}
		},
		onShow:function(e){
			let pages = getCurrentPages();
			let currPage = pages[pages.length-1];
			if (currPage.data.isDoRefresh == true){
				currPage.data.isDoRefresh = false;
				this.getuser();
			}
		},
		onLoad() {
		    this.indicatorDots = uni.getStorageSync('music');
			this.getuser();
		},
		methods:{
			changeIndicatorDots:function(e){
				let music = e.detail.value;
				uni.setStorageSync('music', music);
			},
			outme:function(){
				uni.clearStorageSync();
				uni.navigateTo({
					url:'/pages/index/index'
				})
			},
			editpass:function(){
				uni.navigateTo({
					url:'./changepassword'
				})
			},
			editcard:function(){
				uni.navigateTo({
					url:'./changecard'
				})
			},
			getuser(){
				let info = this.service.getfox();
				if(info[0]){
					this.foxtoken = info[0]['foxtoken'];
					uni.request({
						url: this.service.FOX_URL + 'diamond/get_userinfo',
						method:'POST',
						data: {
							user_key: this.foxtoken
						},
						dataType:'json',
						header:{
							'content-type':'application/x-www-form-urlencoded',
						},
						success: res => {
							// var rest = JSON.stringify(res);
							// console.log(res)
							var rest = res.data;
							if(rest.status == 'success'){
								this.userinfo = rest.msg;
								this.user_card_rz = this.userinfo['user_card_rz']
								// console.log(this.userinfo)
							}else{
								uni.showToast({
									title:rest.msg,
									icon:'none',
									mask:true
								})
							}
						}
					})
				}else{
					uni.reLaunch({
						url:'../logon/login'
					})
				}
			}
		}
		
	}
</script>

<style>
	.has-right-icon image{
		width:40rpx;
		height: 40rpx;
		vertical-align: middle;
		margin-left: 20rpx;
	}
	.swiper-list{
		height: 60rpx;
	}
	.z-yello{
		background: #efb336;
	}
</style>
